<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--  react核心库  -->
    <script src="lib/react.development.js"></script>
    <!--  reactdom:操作DOM  -->
    <script src="lib/react-dom.development.js"></script>
    <script src="lib/babel.min.js"></script>
    <style>
        .active {
            background-color: #BFA;
            width: 200px;
            height: 200px;
        }
    </style>
</head>

<body>
    <!--指定挂载的位置-->
    <div id="root"></div>
</body>
<script type="text/babel">
    // 创建一个React容器
    const root = ReactDOM.createRoot(document.querySelector("#root"))

    class App extends React.Component {
        state = {
            isShow: true
        }
        render() {
            return (
                <>
                    <button onClick={()=>{
                        this.setState({
                            isShow: !(this.state.isShow)
                        })
                    }}>显示和隐藏</button>
                    {/*<div className={this.state.isShow?'active':''}></div>*/}
                    {this.state.isShow && <div className="active"></div>}

                </>

            )
        }
    }




    root.render(<App />)

</script>

</html>